﻿namespace Jim.OA;

/// <summary>
/// 新建流程
/// </summary>
[Sdk("/api/workflow/paService/doCreateRequest","新建流程")]
public class OADoCreateRequestInput : OAUserRequest<OADoCreateRequestOutput>, ISdkCustomDic
{

    [Required(ErrorMessage = "流程主表数据不能为空")]
    public List<OAWorkFlowField> MainData { get; set; }
    /// <summary>
    /// 明细表数据，例子请看注意事项,非必填
    /// </summary>
    public List<OAWorkflowRequestTable> DetailData { get; set; }

    [Required(ErrorMessage = "流程标题不能为空")]
    public string RequestName { get; set; }

    [Required(ErrorMessage = "流程Id不能为空")]
    public string WorkFlowId { get; set; }
    /// <summary>
    /// 签字意见，默认值流程默认意见若未设置则为空，非必填
    /// </summary>
    public string Remark { get; set; }
    /// <summary>
    /// 新建流程是否默认提交到第二节点，可选值为[0 ：不流转 1：流转 (默认)] 
    /// </summary>
    public string IsNextFlow { get; set; } = "1";
    /// <summary>
    /// 新建流程失败是否默认删除流程，可选值为[0 ：不删除 1：删除 (默认)]
    /// </summary>
    public string DelReqFlowFaild { get; set; } = "1";
    /// <summary>
    /// 紧急程度，非必填
    /// </summary>
    public string RequestLevel { get; set; }

    public SdkDictionary Dic()
    {
        SdkDictionary dic = new SdkDictionary();
        dic.Add("workflowId", WorkFlowId);
        dic.Add("requestName", RequestName);
        if (!string.IsNullOrEmpty(RequestLevel)) dic.Add("requestLevel", RequestLevel);
        if (!string.IsNullOrEmpty(Remark)) dic.Add("remark", Remark);
        if (MainData != null) dic.Add("mainData", MainData);
        if (DetailData != null) dic.Add("detailData", DetailData);

        dynamic otherParams = new ExpandoObject();
        if (!string.IsNullOrEmpty(DelReqFlowFaild)) otherParams.delReqFlowFaild = DelReqFlowFaild;
        if (!string.IsNullOrEmpty(IsNextFlow)) otherParams.isnextflow = IsNextFlow;
        dic.Add("otherParams", otherParams);
        return dic;
    }

}


public class OAWorkflowRequestTable
{ 
    public string TableDBName { get; set; }
    
    public List<OAWorkflowRequestTableRecord> WorkflowRequestTableRecords { get; set; }
}

public class OAWorkflowRequestTableRecord
{ 
    public int RecordOrder { get; set; }

    public List<OAWorkFlowField> WorkflowRequestTableFields { get; set; }
}


public class OAWorkFlowField
{
    public string FieldName { get; set; }
}
public class OAWorkFlowField<T>: OAWorkFlowField
{
    public T FieldValue { get; set; }
}

public class OAWorkFlowStringField : OAWorkFlowField<string>
{
}
public class OAWorkFlowNumberField : OAWorkFlowField<string>
{
}
public class OAWorkFlowObjectField : OAWorkFlowField<OAWorkFlowObjectFieldData>
{
}

public class OAWorkFlowObjectFieldData
{
    public string Name { get; set; }
    public string Value { get; set; }
}

/// <summary>
/// OA流程图片字段
/// </summary>
public class OAWorkFlowFileField : OAWorkFlowField<List<OAWorkFlowFileFieldData>>
{

}

/// <summary>
/// OA流程图片字段-数据
/// </summary>
public class OAWorkFlowFileFieldData
{
    public string FileName { get; set; }

    public string FilePath { get; set; }
}



public class OADoCreateRequestOutput : SdkResponse<OAWorkFlowNew>
{
}


public class OAWorkFlowNew
{
    public int RequestId { get; set; }
}
